{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "flower_type_pred_v10.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "3c1ac3ed938140c4be0299f8511d81a1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_ae2b4c6c3d3d4ae09fac651191a55907",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_bba133af7e754bacbedaee9fe7e250f2",
              "IPY_MODEL_011f90193c644c449d3d7d3748239076"
            ]
          }
        },
        "ae2b4c6c3d3d4ae09fac651191a55907": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "bba133af7e754bacbedaee9fe7e250f2": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_a44603130087465892fc14845aac6598",
            "_dom_classes": [],
            "description": "100%",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 7,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 7,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_1c22e3878af94ecdbea5a24e46e1851f"
          }
        },
        "011f90193c644c449d3d7d3748239076": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_26ba84ed08cb4b688defb1d55077d063",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 7/7 [00:02&lt;00:00,  2.41it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_b1bfcfce153f4f658567cf45fe05a1ab"
          }
        },
        "a44603130087465892fc14845aac6598": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "1c22e3878af94ecdbea5a24e46e1851f": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "26ba84ed08cb4b688defb1d55077d063": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "b1bfcfce153f4f658567cf45fe05a1ab": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "91b8fa69b3b44375a7e86b648fac9ed1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_881401009fc146c8b3ccfd64aef6a000",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_b0305c8950be4d9a91167b65848c3b3b",
              "IPY_MODEL_c94a91b8322543f1b268ffad0b0e18ce"
            ]
          }
        },
        "881401009fc146c8b3ccfd64aef6a000": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "b0305c8950be4d9a91167b65848c3b3b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_263d642ce61748c9b616482219d2e8e0",
            "_dom_classes": [],
            "description": "100%",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 7,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 7,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_d9a70814964d405b94293d453cbd4e26"
          }
        },
        "c94a91b8322543f1b268ffad0b0e18ce": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_dc7665ed2a4f49579c4f3c48c7026fd9",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 7/7 [00:01&lt;00:00,  6.10it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_d6999aa49ba34091ac6520b9f6db0a97"
          }
        },
        "263d642ce61748c9b616482219d2e8e0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "d9a70814964d405b94293d453cbd4e26": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "dc7665ed2a4f49579c4f3c48c7026fd9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "d6999aa49ba34091ac6520b9f6db0a97": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        }
      }
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "invb01u8bdOv",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ver = 'v10'"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "VfcmbjtpVLW2",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "from sklearn.model_selection import *\n",
        "from sklearn.preprocessing import *\n",
        "from sklearn.metrics import *\n",
        "from lightgbm import LGBMClassifier\n",
        "from catboost import CatBoostClassifier\n",
        "\n",
        "import gc\n",
        "from tqdm import *"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Zln8E9QHVcyl",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "train = pd.read_csv('Train.csv')\n",
        "test = pd.read_csv('Test.csv')\n",
        "ss = pd.read_csv('sample_submission.csv')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_0qBLg1oV4ML",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "df = pd.concat([train, test]).reset_index(drop = True)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "9KtHa-vCsvoV",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 160
        },
        "outputId": "3eae7c54-6e4e-45e9-f727-f91b6a0f8b4e"
      },
      "source": [
        "df.nunique()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Area_Code        30900\n",
              "Locality_Code       22\n",
              "Region_Code       2185\n",
              "Height             110\n",
              "Diameter           151\n",
              "Class                8\n",
              "Species            263\n",
              "dtype: int64"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3ZxbJMIWs2U_",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "d4805511-e52a-4d88-9838-19b49b19177b"
      },
      "source": [
        "df['Region_Species'] = pd.factorize(df['Region_Code'].astype('str') + df['Species'].astype('str'))[0]\n",
        "df['Region_Species'].nunique()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "17667"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 9
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mtQT91gocqaE",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 53
        },
        "outputId": "d8189e06-37d7-4513-94a0-b840b294bd8c"
      },
      "source": [
        "df['height*diameter'] = df['Height'] * df['Diameter']\n",
        "df['height/diameter'] = df['Height'] / df['Diameter']\n",
        "df['log_diameter'] = np.log(df['Diameter'])"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/pandas/core/series.py:679: RuntimeWarning: divide by zero encountered in log\n",
            "  result = getattr(ufunc, method)(*inputs, **kwargs)\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nA0e07RcQdu8",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "fts = ['Area_Code','Locality_Code','Region_Code','Height','Diameter', 'Species', 'Region_Species']"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Ailk0ELF2ZkJ",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "for f in fts:\n",
        "  df[f + '_freq'] = df[f].map(df[f].value_counts(normalize = True))"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "B_HkJYbic6-Z",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 120,
          "referenced_widgets": [
            "3c1ac3ed938140c4be0299f8511d81a1",
            "ae2b4c6c3d3d4ae09fac651191a55907",
            "bba133af7e754bacbedaee9fe7e250f2",
            "011f90193c644c449d3d7d3748239076",
            "a44603130087465892fc14845aac6598",
            "1c22e3878af94ecdbea5a24e46e1851f",
            "26ba84ed08cb4b688defb1d55077d063",
            "b1bfcfce153f4f658567cf45fe05a1ab"
          ]
        },
        "outputId": "73726f74-4612-48d7-9aaa-ce4290c1880d"
      },
      "source": [
        "cat_fts = ['Area_Code', 'Locality_Code', 'Region_Code', 'Species', 'Region_Species', 'Height', 'Diameter']\n",
        "num_fts_2 = ['Height', 'Diameter','height*diameter', 'height/diameter', 'Locality_Code_freq', 'Species_freq']\n",
        "\n",
        "for g in tqdm_notebook(cat_fts):\n",
        "\n",
        "  num_fts = [c for c in num_fts_2 if c != g]\n",
        "  grp = df.groupby(g)[num_fts].mean()\n",
        "  grp.columns = [c + f'_grpd_by_{g}_mean' for c in grp.columns]\n",
        "  df = pd.merge(df, grp, on = g, how = 'left')\n",
        "\n",
        "  grp = df.groupby(g)[num_fts].std()\n",
        "  grp.columns = [c + f'_grpd_by_{g}_std' for c in grp.columns]\n",
        "  df = pd.merge(df, grp, on = g, how = 'left')\n",
        "\n",
        "  grp = df.groupby(g)[num_fts].min()\n",
        "  grp.columns = [c + f'_grpd_by_{g}_min' for c in grp.columns]\n",
        "  df = pd.merge(df, grp, on = g, how = 'left')\n",
        "\n",
        "  grp = df.groupby(g)[num_fts].max()\n",
        "  grp.columns = [c + f'_grpd_by_{g}_max' for c in grp.columns]\n",
        "  df = pd.merge(df, grp, on = g, how = 'left')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:4: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
            "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
            "  after removing the cwd from sys.path.\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "3c1ac3ed938140c4be0299f8511d81a1",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=0.0, max=7.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QfJ8wl58W2Hz",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 120,
          "referenced_widgets": [
            "91b8fa69b3b44375a7e86b648fac9ed1",
            "881401009fc146c8b3ccfd64aef6a000",
            "b0305c8950be4d9a91167b65848c3b3b",
            "c94a91b8322543f1b268ffad0b0e18ce",
            "263d642ce61748c9b616482219d2e8e0",
            "d9a70814964d405b94293d453cbd4e26",
            "dc7665ed2a4f49579c4f3c48c7026fd9",
            "d6999aa49ba34091ac6520b9f6db0a97"
          ]
        },
        "outputId": "8c05e454-e01e-4b99-ce6b-6a9540276a8b"
      },
      "source": [
        "fts = ['Area_Code','Locality_Code','Region_Code','Height','Diameter', 'Species', 'Region_Species']\n",
        "for g in tqdm_notebook(fts):\n",
        "  rf = [c for c in fts if c != g]\n",
        "  grp = df.groupby(g)[rf].nunique()\n",
        "  grp.columns = [c + f'_grpd_by_{g}_nunique' for c in grp.columns]\n",
        "  df = pd.merge(df, grp, on = g, how = 'left')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:2: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
            "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
            "  \n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "91b8fa69b3b44375a7e86b648fac9ed1",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=0.0, max=7.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jSdWOa2hX7Uc",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "train, test = df[:train.shape[0]].reset_index(drop = True), df[train.shape[0]:].reset_index(drop = True)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ag23_zOcXvxP",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "features = [c for c in train.columns if c not in ['Class', \"Area_Code\", \"Region_Code\", 'Region_Species']]"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "IqV_PDBWpvBb",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "bcf0d0bc-be51-4d40-e31b-ad7d64f4d86b"
      },
      "source": [
        "len(features)"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "216"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BchuAjlmWnFd",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "8c89b49a-a1f6-4afe-d761-1e2b398a6493"
      },
      "source": [
        "oofs = np.zeros((len(train), 8))\n",
        "preds = np.zeros((len(test), 8))\n",
        "N_SPLITS = 15\n",
        "folds = StratifiedKFold(N_SPLITS, shuffle = True, random_state = 77)\n",
        "\n",
        "for fold_, (trn_idx, val_idx) in enumerate(folds.split(train, train['Class'])):\n",
        "\n",
        "  print(f'\\n\\n Fold {fold_} \\\\n\\n')\n",
        "  X_trn, y_trn = train[features].iloc[trn_idx], train[\"Class\"][trn_idx]\n",
        "  X_val, y_val = train[features].iloc[val_idx], train[\"Class\"][val_idx]\n",
        "\n",
        "  # clf = LGBMClassifier(n_estimators = 10000, learning_rate = 0.05, colsample_bytree = 0.5, reg_alpha = 0.5, reg_lambda = 1, random_state = 2)\n",
        "  clf = CatBoostClassifier(iterations = 5000, learning_rate = 0.06, random_state=2, reg_lambda=0.5, eval_metric='MultiClass', task_type = 'GPU')\n",
        "\n",
        "  clf.fit(X_trn, y_trn, eval_set = [(X_val, y_val)], early_stopping_rounds = 150, verbose = 50)\n",
        "\n",
        "  oofs[val_idx] = clf.predict_proba(X_val)\n",
        "  preds += clf.predict_proba(test[features]) / N_SPLITS\n"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\n",
            "\n",
            " Fold 0 \\n\n",
            "\n",
            "0:\tlearn: 1.9185089\ttest: 1.9243102\tbest: 1.9243102 (0)\ttotal: 12.5ms\tremaining: 1m 2s\n",
            "50:\tlearn: 0.8404664\ttest: 0.9106290\tbest: 0.9106290 (50)\ttotal: 548ms\tremaining: 53.2s\n",
            "100:\tlearn: 0.7348459\ttest: 0.8448110\tbest: 0.8448110 (100)\ttotal: 1.05s\tremaining: 50.9s\n",
            "150:\tlearn: 0.6753437\ttest: 0.8176122\tbest: 0.8176122 (150)\ttotal: 1.58s\tremaining: 50.7s\n",
            "200:\tlearn: 0.6287233\ttest: 0.7989932\tbest: 0.7989932 (200)\ttotal: 2.08s\tremaining: 49.7s\n",
            "250:\tlearn: 0.5900514\ttest: 0.7874514\tbest: 0.7874514 (250)\ttotal: 2.61s\tremaining: 49.4s\n",
            "300:\tlearn: 0.5553369\ttest: 0.7750005\tbest: 0.7750005 (300)\ttotal: 3.12s\tremaining: 48.8s\n",
            "350:\tlearn: 0.5255657\ttest: 0.7704437\tbest: 0.7704437 (350)\ttotal: 3.65s\tremaining: 48.3s\n",
            "400:\tlearn: 0.4984768\ttest: 0.7635515\tbest: 0.7635515 (400)\ttotal: 4.17s\tremaining: 47.9s\n",
            "450:\tlearn: 0.4733966\ttest: 0.7579688\tbest: 0.7579688 (450)\ttotal: 4.69s\tremaining: 47.3s\n",
            "500:\tlearn: 0.4509757\ttest: 0.7554362\tbest: 0.7551304 (491)\ttotal: 5.2s\tremaining: 46.7s\n",
            "550:\tlearn: 0.4292673\ttest: 0.7520594\tbest: 0.7520594 (550)\ttotal: 5.71s\tremaining: 46.1s\n",
            "600:\tlearn: 0.4090991\ttest: 0.7517038\tbest: 0.7517038 (600)\ttotal: 6.23s\tremaining: 45.6s\n",
            "650:\tlearn: 0.3911897\ttest: 0.7507584\tbest: 0.7506874 (648)\ttotal: 6.73s\tremaining: 45s\n",
            "700:\tlearn: 0.3749105\ttest: 0.7505859\tbest: 0.7496736 (677)\ttotal: 7.26s\tremaining: 44.5s\n",
            "750:\tlearn: 0.3584162\ttest: 0.7513263\tbest: 0.7496620 (714)\ttotal: 7.78s\tremaining: 44s\n",
            "800:\tlearn: 0.3433246\ttest: 0.7509806\tbest: 0.7496620 (714)\ttotal: 8.31s\tremaining: 43.6s\n",
            "850:\tlearn: 0.3279873\ttest: 0.7476781\tbest: 0.7476781 (850)\ttotal: 8.83s\tremaining: 43.1s\n",
            "900:\tlearn: 0.3145653\ttest: 0.7489113\tbest: 0.7476717 (874)\ttotal: 9.38s\tremaining: 42.7s\n",
            "950:\tlearn: 0.3026045\ttest: 0.7495812\tbest: 0.7476717 (874)\ttotal: 9.9s\tremaining: 42.2s\n",
            "1000:\tlearn: 0.2910498\ttest: 0.7507641\tbest: 0.7476717 (874)\ttotal: 10.4s\tremaining: 41.6s\n",
            "bestTest = 0.7476717074\n",
            "bestIteration = 874\n",
            "Shrink model to first 875 iterations.\n",
            "\n",
            "\n",
            " Fold 1 \\n\n",
            "\n",
            "0:\tlearn: 1.9188798\ttest: 1.9249405\tbest: 1.9249405 (0)\ttotal: 22.1ms\tremaining: 1m 50s\n",
            "50:\tlearn: 0.8430745\ttest: 0.8955355\tbest: 0.8955355 (50)\ttotal: 499ms\tremaining: 48.5s\n",
            "100:\tlearn: 0.7402166\ttest: 0.8299379\tbest: 0.8299379 (100)\ttotal: 989ms\tremaining: 48s\n",
            "150:\tlearn: 0.6811563\ttest: 0.8065119\tbest: 0.8065119 (150)\ttotal: 1.48s\tremaining: 47.6s\n",
            "200:\tlearn: 0.6333897\ttest: 0.7874339\tbest: 0.7874339 (200)\ttotal: 1.97s\tremaining: 47s\n",
            "250:\tlearn: 0.5910817\ttest: 0.7729136\tbest: 0.7729136 (250)\ttotal: 2.46s\tremaining: 46.5s\n",
            "300:\tlearn: 0.5576066\ttest: 0.7652081\tbest: 0.7652081 (300)\ttotal: 2.94s\tremaining: 46s\n",
            "350:\tlearn: 0.5274378\ttest: 0.7585755\tbest: 0.7585755 (350)\ttotal: 3.43s\tremaining: 45.5s\n",
            "400:\tlearn: 0.5000890\ttest: 0.7529386\tbest: 0.7527243 (397)\ttotal: 3.91s\tremaining: 44.9s\n",
            "450:\tlearn: 0.4747557\ttest: 0.7482251\tbest: 0.7479636 (449)\ttotal: 4.4s\tremaining: 44.4s\n",
            "500:\tlearn: 0.4504679\ttest: 0.7447891\tbest: 0.7444282 (498)\ttotal: 4.89s\tremaining: 43.9s\n",
            "550:\tlearn: 0.4295062\ttest: 0.7432255\tbest: 0.7430820 (548)\ttotal: 5.37s\tremaining: 43.4s\n",
            "600:\tlearn: 0.4083843\ttest: 0.7416695\tbest: 0.7412075 (587)\ttotal: 5.87s\tremaining: 42.9s\n",
            "650:\tlearn: 0.3899026\ttest: 0.7405598\tbest: 0.7405318 (649)\ttotal: 6.37s\tremaining: 42.6s\n",
            "700:\tlearn: 0.3729648\ttest: 0.7409172\tbest: 0.7397378 (657)\ttotal: 6.9s\tremaining: 42.3s\n",
            "750:\tlearn: 0.3564376\ttest: 0.7402443\tbest: 0.7396548 (745)\ttotal: 7.42s\tremaining: 42s\n",
            "800:\tlearn: 0.3415201\ttest: 0.7420130\tbest: 0.7394931 (756)\ttotal: 7.94s\tremaining: 41.6s\n",
            "850:\tlearn: 0.3282877\ttest: 0.7419123\tbest: 0.7394931 (756)\ttotal: 8.5s\tremaining: 41.5s\n",
            "900:\tlearn: 0.3141742\ttest: 0.7431425\tbest: 0.7394931 (756)\ttotal: 9.03s\tremaining: 41.1s\n",
            "bestTest = 0.7394931409\n",
            "bestIteration = 756\n",
            "Shrink model to first 757 iterations.\n",
            "\n",
            "\n",
            " Fold 2 \\n\n",
            "\n",
            "0:\tlearn: 1.9179276\ttest: 1.9137638\tbest: 1.9137638 (0)\ttotal: 11.5ms\tremaining: 57.3s\n",
            "50:\tlearn: 0.8432621\ttest: 0.8569461\tbest: 0.8569461 (50)\ttotal: 532ms\tremaining: 51.7s\n",
            "100:\tlearn: 0.7422633\ttest: 0.7827091\tbest: 0.7827091 (100)\ttotal: 1.06s\tremaining: 51.5s\n",
            "150:\tlearn: 0.6817379\ttest: 0.7476772\tbest: 0.7476772 (150)\ttotal: 1.57s\tremaining: 50.6s\n",
            "200:\tlearn: 0.6355758\ttest: 0.7261716\tbest: 0.7261716 (200)\ttotal: 2.1s\tremaining: 50.1s\n",
            "250:\tlearn: 0.5958972\ttest: 0.7126913\tbest: 0.7126913 (250)\ttotal: 2.61s\tremaining: 49.5s\n",
            "300:\tlearn: 0.5609773\ttest: 0.7020681\tbest: 0.7020623 (299)\ttotal: 3.15s\tremaining: 49.1s\n",
            "350:\tlearn: 0.5294807\ttest: 0.6962574\tbest: 0.6959609 (349)\ttotal: 3.66s\tremaining: 48.4s\n",
            "400:\tlearn: 0.5002529\ttest: 0.6900472\tbest: 0.6899959 (396)\ttotal: 4.17s\tremaining: 47.8s\n",
            "450:\tlearn: 0.4757724\ttest: 0.6831198\tbest: 0.6831198 (450)\ttotal: 4.69s\tremaining: 47.3s\n",
            "500:\tlearn: 0.4522432\ttest: 0.6819823\tbest: 0.6819823 (500)\ttotal: 5.21s\tremaining: 46.7s\n",
            "550:\tlearn: 0.4313583\ttest: 0.6802317\tbest: 0.6796745 (533)\ttotal: 5.73s\tremaining: 46.2s\n",
            "600:\tlearn: 0.4102187\ttest: 0.6783241\tbest: 0.6783241 (600)\ttotal: 6.25s\tremaining: 45.7s\n",
            "650:\tlearn: 0.3916926\ttest: 0.6746299\tbest: 0.6745174 (647)\ttotal: 6.77s\tremaining: 45.2s\n",
            "700:\tlearn: 0.3735819\ttest: 0.6718827\tbest: 0.6716184 (695)\ttotal: 7.31s\tremaining: 44.8s\n",
            "750:\tlearn: 0.3568083\ttest: 0.6692680\tbest: 0.6691524 (747)\ttotal: 7.83s\tremaining: 44.3s\n",
            "800:\tlearn: 0.3411268\ttest: 0.6657718\tbest: 0.6652822 (796)\ttotal: 8.35s\tremaining: 43.8s\n",
            "850:\tlearn: 0.3263506\ttest: 0.6664045\tbest: 0.6652822 (796)\ttotal: 8.88s\tremaining: 43.3s\n",
            "900:\tlearn: 0.3134679\ttest: 0.6677981\tbest: 0.6652822 (796)\ttotal: 9.4s\tremaining: 42.8s\n",
            "bestTest = 0.6652821919\n",
            "bestIteration = 796\n",
            "Shrink model to first 797 iterations.\n",
            "\n",
            "\n",
            " Fold 3 \\n\n",
            "\n",
            "0:\tlearn: 1.9198733\ttest: 1.9242728\tbest: 1.9242728 (0)\ttotal: 12.3ms\tremaining: 1m 1s\n",
            "50:\tlearn: 0.8447758\ttest: 0.8887370\tbest: 0.8887370 (50)\ttotal: 548ms\tremaining: 53.2s\n",
            "100:\tlearn: 0.7467278\ttest: 0.8210845\tbest: 0.8210845 (100)\ttotal: 1.08s\tremaining: 52.3s\n",
            "150:\tlearn: 0.6882910\ttest: 0.7937894\tbest: 0.7937894 (150)\ttotal: 1.59s\tremaining: 51s\n",
            "200:\tlearn: 0.6397409\ttest: 0.7726986\tbest: 0.7726986 (200)\ttotal: 2.1s\tremaining: 50.2s\n",
            "250:\tlearn: 0.5966342\ttest: 0.7555010\tbest: 0.7555010 (250)\ttotal: 2.61s\tremaining: 49.5s\n",
            "300:\tlearn: 0.5620235\ttest: 0.7427929\tbest: 0.7424311 (297)\ttotal: 3.13s\tremaining: 48.9s\n",
            "350:\tlearn: 0.5336371\ttest: 0.7356010\tbest: 0.7356010 (350)\ttotal: 3.66s\tremaining: 48.5s\n",
            "400:\tlearn: 0.5068887\ttest: 0.7304427\tbest: 0.7303739 (397)\ttotal: 4.17s\tremaining: 47.8s\n",
            "450:\tlearn: 0.4805513\ttest: 0.7246754\tbest: 0.7246754 (450)\ttotal: 4.67s\tremaining: 47.1s\n",
            "500:\tlearn: 0.4576790\ttest: 0.7194538\tbest: 0.7194538 (500)\ttotal: 5.19s\tremaining: 46.6s\n",
            "550:\tlearn: 0.4347008\ttest: 0.7157434\tbest: 0.7155271 (549)\ttotal: 5.71s\tremaining: 46.1s\n",
            "600:\tlearn: 0.4153480\ttest: 0.7122053\tbest: 0.7121004 (589)\ttotal: 6.21s\tremaining: 45.5s\n",
            "650:\tlearn: 0.3960558\ttest: 0.7114614\tbest: 0.7113114 (634)\ttotal: 6.73s\tremaining: 44.9s\n",
            "700:\tlearn: 0.3773093\ttest: 0.7083141\tbest: 0.7081997 (695)\ttotal: 7.23s\tremaining: 44.3s\n",
            "750:\tlearn: 0.3612904\ttest: 0.7065013\tbest: 0.7062094 (739)\ttotal: 7.72s\tremaining: 43.7s\n",
            "800:\tlearn: 0.3450564\ttest: 0.7046247\tbest: 0.7046247 (800)\ttotal: 8.23s\tremaining: 43.1s\n",
            "850:\tlearn: 0.3299621\ttest: 0.7046677\tbest: 0.7043601 (811)\ttotal: 8.78s\tremaining: 42.8s\n",
            "900:\tlearn: 0.3155901\ttest: 0.7031919\tbest: 0.7029064 (880)\ttotal: 9.27s\tremaining: 42.2s\n",
            "950:\tlearn: 0.3027434\ttest: 0.7032748\tbest: 0.7021325 (938)\ttotal: 9.77s\tremaining: 41.6s\n",
            "1000:\tlearn: 0.2904475\ttest: 0.7023797\tbest: 0.7014151 (972)\ttotal: 10.3s\tremaining: 41s\n",
            "1050:\tlearn: 0.2791964\ttest: 0.7022332\tbest: 0.7014151 (972)\ttotal: 10.8s\tremaining: 40.4s\n",
            "1100:\tlearn: 0.2687723\ttest: 0.7035702\tbest: 0.7014151 (972)\ttotal: 11.2s\tremaining: 39.8s\n",
            "bestTest = 0.7014151489\n",
            "bestIteration = 972\n",
            "Shrink model to first 973 iterations.\n",
            "\n",
            "\n",
            " Fold 4 \\n\n",
            "\n",
            "0:\tlearn: 1.9184737\ttest: 1.9140819\tbest: 1.9140819 (0)\ttotal: 11ms\tremaining: 54.8s\n",
            "50:\tlearn: 0.8488018\ttest: 0.8470265\tbest: 0.8470265 (50)\ttotal: 498ms\tremaining: 48.3s\n",
            "100:\tlearn: 0.7453569\ttest: 0.7750475\tbest: 0.7750475 (100)\ttotal: 995ms\tremaining: 48.3s\n",
            "150:\tlearn: 0.6836557\ttest: 0.7468065\tbest: 0.7468065 (150)\ttotal: 1.5s\tremaining: 48.1s\n",
            "200:\tlearn: 0.6389655\ttest: 0.7308276\tbest: 0.7308276 (200)\ttotal: 1.98s\tremaining: 47.3s\n",
            "250:\tlearn: 0.5979848\ttest: 0.7201550\tbest: 0.7201550 (250)\ttotal: 2.47s\tremaining: 46.7s\n",
            "300:\tlearn: 0.5662915\ttest: 0.7129311\tbest: 0.7129311 (300)\ttotal: 2.95s\tremaining: 46s\n",
            "350:\tlearn: 0.5338067\ttest: 0.7035362\tbest: 0.7035362 (350)\ttotal: 3.44s\tremaining: 45.5s\n",
            "400:\tlearn: 0.5056754\ttest: 0.6986332\tbest: 0.6986332 (400)\ttotal: 3.93s\tremaining: 45s\n",
            "450:\tlearn: 0.4822115\ttest: 0.6957107\tbest: 0.6955415 (448)\ttotal: 4.41s\tremaining: 44.5s\n",
            "500:\tlearn: 0.4570548\ttest: 0.6935050\tbest: 0.6931220 (495)\ttotal: 4.91s\tremaining: 44.1s\n",
            "550:\tlearn: 0.4336538\ttest: 0.6891352\tbest: 0.6891352 (550)\ttotal: 5.4s\tremaining: 43.6s\n",
            "600:\tlearn: 0.4132656\ttest: 0.6873282\tbest: 0.6872147 (599)\ttotal: 5.89s\tremaining: 43.2s\n",
            "650:\tlearn: 0.3940001\ttest: 0.6841353\tbest: 0.6841353 (650)\ttotal: 6.38s\tremaining: 42.6s\n",
            "700:\tlearn: 0.3769645\ttest: 0.6845634\tbest: 0.6840314 (651)\ttotal: 6.89s\tremaining: 42.3s\n",
            "750:\tlearn: 0.3603992\ttest: 0.6843250\tbest: 0.6831058 (726)\ttotal: 7.38s\tremaining: 41.7s\n",
            "800:\tlearn: 0.3450147\ttest: 0.6848383\tbest: 0.6831058 (726)\ttotal: 7.87s\tremaining: 41.3s\n",
            "850:\tlearn: 0.3305122\ttest: 0.6847161\tbest: 0.6831058 (726)\ttotal: 8.37s\tremaining: 40.8s\n",
            "bestTest = 0.6831057577\n",
            "bestIteration = 726\n",
            "Shrink model to first 727 iterations.\n",
            "\n",
            "\n",
            " Fold 5 \\n\n",
            "\n",
            "0:\tlearn: 1.9180798\ttest: 1.9174212\tbest: 1.9174212 (0)\ttotal: 12.1ms\tremaining: 1m\n",
            "50:\tlearn: 0.8423589\ttest: 0.8754873\tbest: 0.8754873 (50)\ttotal: 522ms\tremaining: 50.7s\n",
            "100:\tlearn: 0.7422685\ttest: 0.8070626\tbest: 0.8070626 (100)\ttotal: 1.02s\tremaining: 49.4s\n",
            "150:\tlearn: 0.6822898\ttest: 0.7777936\tbest: 0.7777936 (150)\ttotal: 1.5s\tremaining: 48.1s\n",
            "200:\tlearn: 0.6353640\ttest: 0.7629722\tbest: 0.7629722 (200)\ttotal: 1.98s\tremaining: 47.4s\n",
            "250:\tlearn: 0.5922955\ttest: 0.7498431\tbest: 0.7498431 (250)\ttotal: 2.48s\tremaining: 47s\n",
            "300:\tlearn: 0.5575357\ttest: 0.7419110\tbest: 0.7419110 (300)\ttotal: 3s\tremaining: 46.9s\n",
            "350:\tlearn: 0.5287903\ttest: 0.7384469\tbest: 0.7381840 (346)\ttotal: 3.52s\tremaining: 46.7s\n",
            "400:\tlearn: 0.5011645\ttest: 0.7326696\tbest: 0.7326696 (400)\ttotal: 4.03s\tremaining: 46.2s\n",
            "450:\tlearn: 0.4750690\ttest: 0.7285952\tbest: 0.7283785 (448)\ttotal: 4.52s\tremaining: 45.6s\n",
            "500:\tlearn: 0.4524986\ttest: 0.7254230\tbest: 0.7252333 (492)\ttotal: 5.01s\tremaining: 45s\n",
            "550:\tlearn: 0.4302797\ttest: 0.7228668\tbest: 0.7226193 (549)\ttotal: 5.52s\tremaining: 44.6s\n",
            "600:\tlearn: 0.4115347\ttest: 0.7207940\tbest: 0.7205350 (588)\ttotal: 6.05s\tremaining: 44.3s\n",
            "650:\tlearn: 0.3925639\ttest: 0.7173700\tbest: 0.7173650 (649)\ttotal: 6.58s\tremaining: 43.9s\n",
            "700:\tlearn: 0.3766693\ttest: 0.7180253\tbest: 0.7173559 (652)\ttotal: 7.09s\tremaining: 43.5s\n",
            "750:\tlearn: 0.3584870\ttest: 0.7167616\tbest: 0.7164630 (748)\ttotal: 7.62s\tremaining: 43.1s\n",
            "800:\tlearn: 0.3442760\ttest: 0.7164611\tbest: 0.7161635 (795)\ttotal: 8.13s\tremaining: 42.6s\n",
            "850:\tlearn: 0.3296782\ttest: 0.7152259\tbest: 0.7151353 (849)\ttotal: 8.66s\tremaining: 42.2s\n",
            "900:\tlearn: 0.3163908\ttest: 0.7162131\tbest: 0.7149063 (862)\ttotal: 9.16s\tremaining: 41.7s\n",
            "950:\tlearn: 0.3035377\ttest: 0.7172609\tbest: 0.7149063 (862)\ttotal: 9.65s\tremaining: 41.1s\n",
            "1000:\tlearn: 0.2907201\ttest: 0.7167738\tbest: 0.7149063 (862)\ttotal: 10.1s\tremaining: 40.5s\n",
            "bestTest = 0.714906302\n",
            "bestIteration = 862\n",
            "Shrink model to first 863 iterations.\n",
            "\n",
            "\n",
            " Fold 6 \\n\n",
            "\n",
            "0:\tlearn: 1.9183960\ttest: 1.9153792\tbest: 1.9153792 (0)\ttotal: 11ms\tremaining: 55s\n",
            "50:\tlearn: 0.8437588\ttest: 0.8463548\tbest: 0.8463548 (50)\ttotal: 506ms\tremaining: 49.1s\n",
            "100:\tlearn: 0.7407464\ttest: 0.7795073\tbest: 0.7795073 (100)\ttotal: 996ms\tremaining: 48.3s\n",
            "150:\tlearn: 0.6858391\ttest: 0.7576392\tbest: 0.7576392 (150)\ttotal: 1.47s\tremaining: 47.4s\n",
            "200:\tlearn: 0.6379132\ttest: 0.7411078\tbest: 0.7409085 (193)\ttotal: 1.97s\tremaining: 47.1s\n",
            "250:\tlearn: 0.5972075\ttest: 0.7307926\tbest: 0.7307926 (250)\ttotal: 2.46s\tremaining: 46.6s\n",
            "300:\tlearn: 0.5601628\ttest: 0.7256021\tbest: 0.7255631 (298)\ttotal: 2.95s\tremaining: 46.1s\n",
            "350:\tlearn: 0.5282597\ttest: 0.7190691\tbest: 0.7190691 (350)\ttotal: 3.42s\tremaining: 45.4s\n",
            "400:\tlearn: 0.4993656\ttest: 0.7139990\tbest: 0.7139990 (400)\ttotal: 3.93s\tremaining: 45s\n",
            "450:\tlearn: 0.4742842\ttest: 0.7115479\tbest: 0.7115479 (450)\ttotal: 4.4s\tremaining: 44.4s\n",
            "500:\tlearn: 0.4498766\ttest: 0.7104514\tbest: 0.7104514 (500)\ttotal: 4.91s\tremaining: 44.1s\n",
            "550:\tlearn: 0.4298744\ttest: 0.7102156\tbest: 0.7086284 (526)\ttotal: 5.39s\tremaining: 43.5s\n",
            "600:\tlearn: 0.4099771\ttest: 0.7088778\tbest: 0.7086284 (526)\ttotal: 5.89s\tremaining: 43.1s\n",
            "650:\tlearn: 0.3920980\ttest: 0.7066289\tbest: 0.7066289 (650)\ttotal: 6.37s\tremaining: 42.5s\n",
            "700:\tlearn: 0.3748203\ttest: 0.7073056\tbest: 0.7063909 (666)\ttotal: 6.86s\tremaining: 42.1s\n",
            "750:\tlearn: 0.3588942\ttest: 0.7064124\tbest: 0.7062304 (749)\ttotal: 7.35s\tremaining: 41.6s\n",
            "800:\tlearn: 0.3441857\ttest: 0.7075490\tbest: 0.7059603 (755)\ttotal: 7.91s\tremaining: 41.5s\n",
            "850:\tlearn: 0.3296365\ttest: 0.7064461\tbest: 0.7059603 (755)\ttotal: 8.41s\tremaining: 41s\n",
            "900:\tlearn: 0.3167799\ttest: 0.7084641\tbest: 0.7059603 (755)\ttotal: 8.94s\tremaining: 40.7s\n",
            "bestTest = 0.7059603144\n",
            "bestIteration = 755\n",
            "Shrink model to first 756 iterations.\n",
            "\n",
            "\n",
            " Fold 7 \\n\n",
            "\n",
            "0:\tlearn: 1.9175067\ttest: 1.9210351\tbest: 1.9210351 (0)\ttotal: 11.9ms\tremaining: 59.7s\n",
            "50:\tlearn: 0.8413335\ttest: 0.9146628\tbest: 0.9146628 (50)\ttotal: 526ms\tremaining: 51s\n",
            "100:\tlearn: 0.7380363\ttest: 0.8588446\tbest: 0.8588446 (100)\ttotal: 1.05s\tremaining: 50.7s\n",
            "150:\tlearn: 0.6771903\ttest: 0.8346687\tbest: 0.8346687 (150)\ttotal: 1.56s\tremaining: 50.2s\n",
            "200:\tlearn: 0.6329789\ttest: 0.8249262\tbest: 0.8249262 (200)\ttotal: 2.06s\tremaining: 49.2s\n",
            "250:\tlearn: 0.5934418\ttest: 0.8136501\tbest: 0.8136501 (250)\ttotal: 2.55s\tremaining: 48.3s\n",
            "300:\tlearn: 0.5601994\ttest: 0.8091020\tbest: 0.8089650 (295)\ttotal: 3.04s\tremaining: 47.4s\n",
            "350:\tlearn: 0.5284430\ttest: 0.8065557\tbest: 0.8062530 (340)\ttotal: 3.54s\tremaining: 46.8s\n",
            "400:\tlearn: 0.5013675\ttest: 0.8020806\tbest: 0.8020806 (400)\ttotal: 4.03s\tremaining: 46.2s\n",
            "450:\tlearn: 0.4757520\ttest: 0.7989648\tbest: 0.7987917 (428)\ttotal: 4.52s\tremaining: 45.6s\n",
            "500:\tlearn: 0.4536851\ttest: 0.7977797\tbest: 0.7975417 (496)\ttotal: 5.02s\tremaining: 45.1s\n",
            "550:\tlearn: 0.4312243\ttest: 0.7971556\tbest: 0.7967759 (544)\ttotal: 5.51s\tremaining: 44.5s\n",
            "600:\tlearn: 0.4109930\ttest: 0.7964940\tbest: 0.7963291 (570)\ttotal: 6.01s\tremaining: 44s\n",
            "650:\tlearn: 0.3929175\ttest: 0.7957631\tbest: 0.7956659 (644)\ttotal: 6.5s\tremaining: 43.4s\n",
            "700:\tlearn: 0.3758089\ttest: 0.7973137\tbest: 0.7952295 (656)\ttotal: 6.99s\tremaining: 42.9s\n",
            "750:\tlearn: 0.3599906\ttest: 0.7979945\tbest: 0.7952295 (656)\ttotal: 7.48s\tremaining: 42.3s\n",
            "800:\tlearn: 0.3444737\ttest: 0.8013753\tbest: 0.7952295 (656)\ttotal: 7.98s\tremaining: 41.8s\n",
            "bestTest = 0.7952295095\n",
            "bestIteration = 656\n",
            "Shrink model to first 657 iterations.\n",
            "\n",
            "\n",
            " Fold 8 \\n\n",
            "\n",
            "0:\tlearn: 1.9204639\ttest: 1.9186121\tbest: 1.9186121 (0)\ttotal: 11.9ms\tremaining: 59.6s\n",
            "50:\tlearn: 0.8446031\ttest: 0.8514694\tbest: 0.8514694 (50)\ttotal: 536ms\tremaining: 52s\n",
            "100:\tlearn: 0.7426345\ttest: 0.7785924\tbest: 0.7785924 (100)\ttotal: 1.03s\tremaining: 49.9s\n",
            "150:\tlearn: 0.6824820\ttest: 0.7531000\tbest: 0.7531000 (150)\ttotal: 1.53s\tremaining: 49.2s\n",
            "200:\tlearn: 0.6376788\ttest: 0.7399405\tbest: 0.7396160 (194)\ttotal: 2.01s\tremaining: 48s\n",
            "250:\tlearn: 0.5973877\ttest: 0.7322770\tbest: 0.7322770 (250)\ttotal: 2.52s\tremaining: 47.7s\n",
            "300:\tlearn: 0.5642898\ttest: 0.7276837\tbest: 0.7276837 (300)\ttotal: 3s\tremaining: 46.8s\n",
            "350:\tlearn: 0.5318426\ttest: 0.7268394\tbest: 0.7261481 (345)\ttotal: 3.5s\tremaining: 46.4s\n",
            "400:\tlearn: 0.5037778\ttest: 0.7240428\tbest: 0.7232956 (391)\ttotal: 3.99s\tremaining: 45.8s\n",
            "450:\tlearn: 0.4767529\ttest: 0.7216192\tbest: 0.7216098 (447)\ttotal: 4.5s\tremaining: 45.4s\n",
            "500:\tlearn: 0.4530005\ttest: 0.7199962\tbest: 0.7194698 (474)\ttotal: 4.98s\tremaining: 44.7s\n",
            "550:\tlearn: 0.4299721\ttest: 0.7201472\tbest: 0.7190968 (522)\ttotal: 5.49s\tremaining: 44.3s\n",
            "600:\tlearn: 0.4103708\ttest: 0.7195293\tbest: 0.7190674 (594)\ttotal: 5.97s\tremaining: 43.7s\n",
            "650:\tlearn: 0.3920880\ttest: 0.7197530\tbest: 0.7188470 (614)\ttotal: 6.48s\tremaining: 43.3s\n",
            "700:\tlearn: 0.3742891\ttest: 0.7174828\tbest: 0.7174702 (699)\ttotal: 6.95s\tremaining: 42.6s\n",
            "750:\tlearn: 0.3575417\ttest: 0.7204200\tbest: 0.7169788 (706)\ttotal: 7.46s\tremaining: 42.2s\n",
            "800:\tlearn: 0.3417976\ttest: 0.7206189\tbest: 0.7169788 (706)\ttotal: 7.97s\tremaining: 41.8s\n",
            "850:\tlearn: 0.3278160\ttest: 0.7207095\tbest: 0.7169788 (706)\ttotal: 8.5s\tremaining: 41.4s\n",
            "bestTest = 0.7169787511\n",
            "bestIteration = 706\n",
            "Shrink model to first 707 iterations.\n",
            "\n",
            "\n",
            " Fold 9 \\n\n",
            "\n",
            "0:\tlearn: 1.9194908\ttest: 1.9216891\tbest: 1.9216891 (0)\ttotal: 11.4ms\tremaining: 56.9s\n",
            "50:\tlearn: 0.8408298\ttest: 0.8823681\tbest: 0.8823681 (50)\ttotal: 529ms\tremaining: 51.4s\n",
            "100:\tlearn: 0.7376753\ttest: 0.8195994\tbest: 0.8195994 (100)\ttotal: 1.06s\tremaining: 51.4s\n",
            "150:\tlearn: 0.6798630\ttest: 0.7955635\tbest: 0.7955635 (150)\ttotal: 1.57s\tremaining: 50.4s\n",
            "200:\tlearn: 0.6326637\ttest: 0.7821925\tbest: 0.7821925 (200)\ttotal: 2.08s\tremaining: 49.6s\n",
            "250:\tlearn: 0.5910495\ttest: 0.7723725\tbest: 0.7723725 (250)\ttotal: 2.59s\tremaining: 49s\n",
            "300:\tlearn: 0.5547410\ttest: 0.7681071\tbest: 0.7681071 (300)\ttotal: 3.11s\tremaining: 48.6s\n",
            "350:\tlearn: 0.5252049\ttest: 0.7626224\tbest: 0.7626224 (350)\ttotal: 3.62s\tremaining: 48s\n",
            "400:\tlearn: 0.4976349\ttest: 0.7580909\tbest: 0.7577131 (389)\ttotal: 4.13s\tremaining: 47.3s\n",
            "450:\tlearn: 0.4731789\ttest: 0.7560559\tbest: 0.7557807 (447)\ttotal: 4.62s\tremaining: 46.6s\n",
            "500:\tlearn: 0.4487118\ttest: 0.7550440\tbest: 0.7550440 (500)\ttotal: 5.12s\tremaining: 46s\n",
            "550:\tlearn: 0.4258904\ttest: 0.7541111\tbest: 0.7541111 (550)\ttotal: 5.61s\tremaining: 45.3s\n",
            "600:\tlearn: 0.4053593\ttest: 0.7552735\tbest: 0.7541111 (550)\ttotal: 6.11s\tremaining: 44.7s\n",
            "650:\tlearn: 0.3862842\ttest: 0.7563332\tbest: 0.7541111 (550)\ttotal: 6.62s\tremaining: 44.2s\n",
            "700:\tlearn: 0.3692526\ttest: 0.7540262\tbest: 0.7529023 (683)\ttotal: 7.15s\tremaining: 43.9s\n",
            "750:\tlearn: 0.3530377\ttest: 0.7527188\tbest: 0.7521622 (731)\ttotal: 7.67s\tremaining: 43.4s\n",
            "800:\tlearn: 0.3387184\ttest: 0.7535134\tbest: 0.7520253 (771)\ttotal: 8.2s\tremaining: 43s\n",
            "850:\tlearn: 0.3241984\ttest: 0.7541360\tbest: 0.7520253 (771)\ttotal: 8.71s\tremaining: 42.4s\n",
            "900:\tlearn: 0.3105106\ttest: 0.7552386\tbest: 0.7520253 (771)\ttotal: 9.24s\tremaining: 42s\n",
            "bestTest = 0.7520252969\n",
            "bestIteration = 771\n",
            "Shrink model to first 772 iterations.\n",
            "\n",
            "\n",
            " Fold 10 \\n\n",
            "\n",
            "0:\tlearn: 1.9202307\ttest: 1.9172739\tbest: 1.9172739 (0)\ttotal: 10.9ms\tremaining: 54.3s\n",
            "50:\tlearn: 0.8444998\ttest: 0.8677461\tbest: 0.8677461 (50)\ttotal: 499ms\tremaining: 48.4s\n",
            "100:\tlearn: 0.7371966\ttest: 0.8088650\tbest: 0.8088650 (100)\ttotal: 990ms\tremaining: 48s\n",
            "150:\tlearn: 0.6762005\ttest: 0.7869522\tbest: 0.7869522 (150)\ttotal: 1.48s\tremaining: 47.7s\n",
            "200:\tlearn: 0.6303457\ttest: 0.7722217\tbest: 0.7722217 (200)\ttotal: 1.98s\tremaining: 47.2s\n",
            "250:\tlearn: 0.5876801\ttest: 0.7631985\tbest: 0.7631985 (250)\ttotal: 2.46s\tremaining: 46.6s\n",
            "300:\tlearn: 0.5532663\ttest: 0.7559753\tbest: 0.7559753 (300)\ttotal: 2.96s\tremaining: 46.2s\n",
            "350:\tlearn: 0.5251818\ttest: 0.7481925\tbest: 0.7481925 (350)\ttotal: 3.43s\tremaining: 45.5s\n",
            "400:\tlearn: 0.4971887\ttest: 0.7441728\tbest: 0.7439892 (392)\ttotal: 3.93s\tremaining: 45.1s\n",
            "450:\tlearn: 0.4700646\ttest: 0.7423282\tbest: 0.7422359 (444)\ttotal: 4.43s\tremaining: 44.7s\n",
            "500:\tlearn: 0.4454128\ttest: 0.7405975\tbest: 0.7403864 (499)\ttotal: 4.93s\tremaining: 44.3s\n",
            "550:\tlearn: 0.4251866\ttest: 0.7402759\tbest: 0.7402347 (537)\ttotal: 5.41s\tremaining: 43.7s\n",
            "600:\tlearn: 0.4052384\ttest: 0.7408673\tbest: 0.7401559 (551)\ttotal: 5.91s\tremaining: 43.2s\n",
            "650:\tlearn: 0.3879959\ttest: 0.7412527\tbest: 0.7401559 (551)\ttotal: 6.39s\tremaining: 42.7s\n",
            "700:\tlearn: 0.3697379\ttest: 0.7403332\tbest: 0.7401559 (551)\ttotal: 6.87s\tremaining: 42.2s\n",
            "bestTest = 0.7401559116\n",
            "bestIteration = 551\n",
            "Shrink model to first 552 iterations.\n",
            "\n",
            "\n",
            " Fold 11 \\n\n",
            "\n",
            "0:\tlearn: 1.9193331\ttest: 1.9233144\tbest: 1.9233144 (0)\ttotal: 12.1ms\tremaining: 1m\n",
            "50:\tlearn: 0.8437825\ttest: 0.8799645\tbest: 0.8799645 (50)\ttotal: 539ms\tremaining: 52.3s\n",
            "100:\tlearn: 0.7374088\ttest: 0.8133341\tbest: 0.8133341 (100)\ttotal: 1.05s\tremaining: 51.1s\n",
            "150:\tlearn: 0.6783854\ttest: 0.7885817\tbest: 0.7885817 (150)\ttotal: 1.57s\tremaining: 50.6s\n",
            "200:\tlearn: 0.6331072\ttest: 0.7762611\tbest: 0.7762611 (200)\ttotal: 2.08s\tremaining: 49.7s\n",
            "250:\tlearn: 0.5927270\ttest: 0.7646452\tbest: 0.7646452 (250)\ttotal: 2.61s\tremaining: 49.4s\n",
            "300:\tlearn: 0.5567561\ttest: 0.7598838\tbest: 0.7598838 (300)\ttotal: 3.12s\tremaining: 48.8s\n",
            "350:\tlearn: 0.5237897\ttest: 0.7587276\tbest: 0.7586605 (348)\ttotal: 3.67s\tremaining: 48.6s\n",
            "400:\tlearn: 0.4956300\ttest: 0.7560821\tbest: 0.7559173 (398)\ttotal: 4.17s\tremaining: 47.8s\n",
            "450:\tlearn: 0.4712524\ttest: 0.7540612\tbest: 0.7538291 (445)\ttotal: 4.7s\tremaining: 47.4s\n",
            "500:\tlearn: 0.4473828\ttest: 0.7511211\tbest: 0.7510162 (499)\ttotal: 5.22s\tremaining: 46.9s\n",
            "550:\tlearn: 0.4267754\ttest: 0.7522698\tbest: 0.7510162 (499)\ttotal: 5.75s\tremaining: 46.4s\n",
            "600:\tlearn: 0.4064908\ttest: 0.7521357\tbest: 0.7510162 (499)\ttotal: 6.27s\tremaining: 45.9s\n",
            "650:\tlearn: 0.3888251\ttest: 0.7496736\tbest: 0.7494289 (646)\ttotal: 6.8s\tremaining: 45.4s\n",
            "700:\tlearn: 0.3712460\ttest: 0.7493369\tbest: 0.7492213 (696)\ttotal: 7.32s\tremaining: 44.9s\n",
            "750:\tlearn: 0.3551896\ttest: 0.7500726\tbest: 0.7491099 (702)\ttotal: 7.86s\tremaining: 44.5s\n",
            "800:\tlearn: 0.3400543\ttest: 0.7519371\tbest: 0.7491099 (702)\ttotal: 8.37s\tremaining: 43.9s\n",
            "850:\tlearn: 0.3265948\ttest: 0.7519848\tbest: 0.7491099 (702)\ttotal: 8.9s\tremaining: 43.4s\n",
            "bestTest = 0.7491098558\n",
            "bestIteration = 702\n",
            "Shrink model to first 703 iterations.\n",
            "\n",
            "\n",
            " Fold 12 \\n\n",
            "\n",
            "0:\tlearn: 1.9199534\ttest: 1.9166354\tbest: 1.9166354 (0)\ttotal: 11.9ms\tremaining: 59.4s\n",
            "50:\tlearn: 0.8487263\ttest: 0.8481586\tbest: 0.8481586 (50)\ttotal: 522ms\tremaining: 50.7s\n",
            "100:\tlearn: 0.7427220\ttest: 0.7763886\tbest: 0.7763886 (100)\ttotal: 1.06s\tremaining: 51.3s\n",
            "150:\tlearn: 0.6832465\ttest: 0.7516579\tbest: 0.7516579 (150)\ttotal: 1.58s\tremaining: 50.6s\n",
            "200:\tlearn: 0.6337948\ttest: 0.7340325\tbest: 0.7340325 (200)\ttotal: 2.11s\tremaining: 50.4s\n",
            "250:\tlearn: 0.5933225\ttest: 0.7291095\tbest: 0.7289257 (249)\ttotal: 2.62s\tremaining: 49.7s\n",
            "300:\tlearn: 0.5596855\ttest: 0.7218263\tbest: 0.7218263 (300)\ttotal: 3.15s\tremaining: 49.2s\n",
            "350:\tlearn: 0.5293803\ttest: 0.7173857\tbest: 0.7173857 (350)\ttotal: 3.65s\tremaining: 48.4s\n",
            "400:\tlearn: 0.5014164\ttest: 0.7135326\tbest: 0.7134250 (398)\ttotal: 4.2s\tremaining: 48.1s\n",
            "450:\tlearn: 0.4771030\ttest: 0.7091567\tbest: 0.7091558 (449)\ttotal: 4.7s\tremaining: 47.4s\n",
            "500:\tlearn: 0.4538724\ttest: 0.7066727\tbest: 0.7059965 (491)\ttotal: 5.22s\tremaining: 46.9s\n",
            "550:\tlearn: 0.4325960\ttest: 0.7040350\tbest: 0.7040350 (550)\ttotal: 5.73s\tremaining: 46.2s\n",
            "600:\tlearn: 0.4133153\ttest: 0.7025004\tbest: 0.7024154 (597)\ttotal: 6.25s\tremaining: 45.8s\n",
            "650:\tlearn: 0.3929071\ttest: 0.7027019\tbest: 0.7017487 (634)\ttotal: 6.75s\tremaining: 45.1s\n",
            "700:\tlearn: 0.3749735\ttest: 0.7007662\tbest: 0.7007662 (700)\ttotal: 7.29s\tremaining: 44.7s\n",
            "750:\tlearn: 0.3592013\ttest: 0.7011905\tbest: 0.6999332 (717)\ttotal: 7.8s\tremaining: 44.2s\n",
            "800:\tlearn: 0.3451162\ttest: 0.6992698\tbest: 0.6992698 (800)\ttotal: 8.32s\tremaining: 43.6s\n",
            "850:\tlearn: 0.3310790\ttest: 0.6980128\tbest: 0.6974461 (830)\ttotal: 8.84s\tremaining: 43.1s\n",
            "900:\tlearn: 0.3181960\ttest: 0.6970915\tbest: 0.6970302 (870)\ttotal: 9.36s\tremaining: 42.6s\n",
            "950:\tlearn: 0.3056177\ttest: 0.6985925\tbest: 0.6970302 (870)\ttotal: 9.88s\tremaining: 42.1s\n",
            "1000:\tlearn: 0.2944211\ttest: 0.6992240\tbest: 0.6970302 (870)\ttotal: 10.4s\tremaining: 41.6s\n",
            "bestTest = 0.6970302347\n",
            "bestIteration = 870\n",
            "Shrink model to first 871 iterations.\n",
            "\n",
            "\n",
            " Fold 13 \\n\n",
            "\n",
            "0:\tlearn: 1.9179891\ttest: 1.9210470\tbest: 1.9210470 (0)\ttotal: 12.2ms\tremaining: 1m 1s\n",
            "50:\tlearn: 0.8452906\ttest: 0.8996819\tbest: 0.8996819 (50)\ttotal: 562ms\tremaining: 54.6s\n",
            "100:\tlearn: 0.7405027\ttest: 0.8337230\tbest: 0.8337230 (100)\ttotal: 1.08s\tremaining: 52.6s\n",
            "150:\tlearn: 0.6846318\ttest: 0.8098132\tbest: 0.8098132 (150)\ttotal: 1.62s\tremaining: 52s\n",
            "200:\tlearn: 0.6388089\ttest: 0.7926686\tbest: 0.7926686 (200)\ttotal: 2.12s\tremaining: 50.7s\n",
            "250:\tlearn: 0.5991524\ttest: 0.7803926\tbest: 0.7803926 (250)\ttotal: 2.65s\tremaining: 50.2s\n",
            "300:\tlearn: 0.5640519\ttest: 0.7714561\tbest: 0.7714561 (300)\ttotal: 3.17s\tremaining: 49.5s\n",
            "350:\tlearn: 0.5316260\ttest: 0.7617317\tbest: 0.7617317 (350)\ttotal: 3.7s\tremaining: 49.1s\n",
            "400:\tlearn: 0.5008852\ttest: 0.7567437\tbest: 0.7567095 (399)\ttotal: 4.22s\tremaining: 48.4s\n",
            "450:\tlearn: 0.4770071\ttest: 0.7539364\tbest: 0.7539364 (450)\ttotal: 4.76s\tremaining: 48s\n",
            "500:\tlearn: 0.4524687\ttest: 0.7517274\tbest: 0.7512916 (490)\ttotal: 5.25s\tremaining: 47.2s\n",
            "550:\tlearn: 0.4298259\ttest: 0.7498246\tbest: 0.7495139 (531)\ttotal: 5.77s\tremaining: 46.6s\n",
            "600:\tlearn: 0.4095382\ttest: 0.7482960\tbest: 0.7482737 (599)\ttotal: 6.26s\tremaining: 45.8s\n",
            "650:\tlearn: 0.3901796\ttest: 0.7449187\tbest: 0.7449027 (649)\ttotal: 6.78s\tremaining: 45.3s\n",
            "700:\tlearn: 0.3722052\ttest: 0.7439389\tbest: 0.7437318 (688)\ttotal: 7.27s\tremaining: 44.6s\n",
            "750:\tlearn: 0.3560146\ttest: 0.7427994\tbest: 0.7427638 (733)\ttotal: 7.79s\tremaining: 44.1s\n",
            "800:\tlearn: 0.3418965\ttest: 0.7428825\tbest: 0.7423998 (755)\ttotal: 8.28s\tremaining: 43.4s\n",
            "850:\tlearn: 0.3284544\ttest: 0.7423058\tbest: 0.7417386 (847)\ttotal: 8.8s\tremaining: 42.9s\n",
            "900:\tlearn: 0.3149242\ttest: 0.7421990\tbest: 0.7411931 (872)\ttotal: 9.29s\tremaining: 42.3s\n",
            "950:\tlearn: 0.3030022\ttest: 0.7431263\tbest: 0.7411931 (872)\ttotal: 9.81s\tremaining: 41.8s\n",
            "1000:\tlearn: 0.2908620\ttest: 0.7450495\tbest: 0.7411931 (872)\ttotal: 10.3s\tremaining: 41.1s\n",
            "bestTest = 0.7411931476\n",
            "bestIteration = 872\n",
            "Shrink model to first 873 iterations.\n",
            "\n",
            "\n",
            " Fold 14 \\n\n",
            "\n",
            "0:\tlearn: 1.9196019\ttest: 1.9259839\tbest: 1.9259839 (0)\ttotal: 11.1ms\tremaining: 55.5s\n",
            "50:\tlearn: 0.8416612\ttest: 0.8977949\tbest: 0.8977949 (50)\ttotal: 502ms\tremaining: 48.7s\n",
            "100:\tlearn: 0.7399415\ttest: 0.8321357\tbest: 0.8321357 (100)\ttotal: 976ms\tremaining: 47.3s\n",
            "150:\tlearn: 0.6779995\ttest: 0.8000334\tbest: 0.8000334 (150)\ttotal: 1.5s\tremaining: 48.1s\n",
            "200:\tlearn: 0.6319001\ttest: 0.7813394\tbest: 0.7813394 (200)\ttotal: 1.98s\tremaining: 47.2s\n",
            "250:\tlearn: 0.5925713\ttest: 0.7675814\tbest: 0.7675814 (250)\ttotal: 2.48s\tremaining: 46.9s\n",
            "300:\tlearn: 0.5604969\ttest: 0.7606005\tbest: 0.7606005 (300)\ttotal: 2.95s\tremaining: 46s\n",
            "350:\tlearn: 0.5297634\ttest: 0.7510937\tbest: 0.7510937 (350)\ttotal: 3.45s\tremaining: 45.7s\n",
            "400:\tlearn: 0.5029065\ttest: 0.7478468\tbest: 0.7475680 (392)\ttotal: 3.92s\tremaining: 45s\n",
            "450:\tlearn: 0.4785479\ttest: 0.7460203\tbest: 0.7459775 (443)\ttotal: 4.42s\tremaining: 44.6s\n",
            "500:\tlearn: 0.4562263\ttest: 0.7440652\tbest: 0.7440047 (494)\ttotal: 4.89s\tremaining: 43.9s\n",
            "550:\tlearn: 0.4344399\ttest: 0.7419635\tbest: 0.7418823 (547)\ttotal: 5.39s\tremaining: 43.5s\n",
            "600:\tlearn: 0.4128736\ttest: 0.7420390\tbest: 0.7409165 (585)\ttotal: 5.88s\tremaining: 43.1s\n",
            "650:\tlearn: 0.3924331\ttest: 0.7390277\tbest: 0.7389405 (636)\ttotal: 6.37s\tremaining: 42.5s\n",
            "700:\tlearn: 0.3753713\ttest: 0.7375164\tbest: 0.7370109 (697)\ttotal: 6.87s\tremaining: 42.1s\n",
            "750:\tlearn: 0.3600062\ttest: 0.7371550\tbest: 0.7365991 (739)\ttotal: 7.35s\tremaining: 41.6s\n",
            "800:\tlearn: 0.3456046\ttest: 0.7371166\tbest: 0.7365991 (739)\ttotal: 7.85s\tremaining: 41.2s\n",
            "850:\tlearn: 0.3312669\ttest: 0.7389773\tbest: 0.7365455 (813)\ttotal: 8.34s\tremaining: 40.7s\n",
            "900:\tlearn: 0.3171405\ttest: 0.7394596\tbest: 0.7365455 (813)\ttotal: 8.84s\tremaining: 40.2s\n",
            "950:\tlearn: 0.3033201\ttest: 0.7418950\tbest: 0.7365455 (813)\ttotal: 9.32s\tremaining: 39.7s\n",
            "bestTest = 0.7365455085\n",
            "bestIteration = 813\n",
            "Shrink model to first 814 iterations.\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qT1rSXSha9BP",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "39152737-f11e-419c-edc2-e8455a308460"
      },
      "source": [
        "oof_val_score = log_loss(train['Class'], oofs)\n",
        "print(f'Final Log loss: {oof_val_score}')"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Final Log loss: 0.7257320709221037\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mJN9Uq2CaDYa",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "ss[ss.columns.tolist()] = preds"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eMKXozZFaK4s",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 17
        },
        "outputId": "73ae0873-2462-4685-958e-d3c4c2a5b9f3"
      },
      "source": [
        "SUB_FILE_NAME = f'mft_{ver}.csv'\n",
        "ss.to_csv(SUB_FILE_NAME, index=False)"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "application/javascript": [
              "\n",
              "    async function download(id, filename, size) {\n",
              "      if (!google.colab.kernel.accessAllowed) {\n",
              "        return;\n",
              "      }\n",
              "      const div = document.createElement('div');\n",
              "      const label = document.createElement('label');\n",
              "      label.textContent = `Downloading \"${filename}\": `;\n",
              "      div.appendChild(label);\n",
              "      const progress = document.createElement('progress');\n",
              "      progress.max = size;\n",
              "      div.appendChild(progress);\n",
              "      document.body.appendChild(div);\n",
              "\n",
              "      const buffers = [];\n",
              "      let downloaded = 0;\n",
              "\n",
              "      const channel = await google.colab.kernel.comms.open(id);\n",
              "      // Send a message to notify the kernel that we're ready.\n",
              "      channel.send({})\n",
              "\n",
              "      for await (const message of channel.messages) {\n",
              "        // Send a message to notify the kernel that we're ready.\n",
              "        channel.send({})\n",
              "        if (message.buffers) {\n",
              "          for (const buffer of message.buffers) {\n",
              "            buffers.push(buffer);\n",
              "            downloaded += buffer.byteLength;\n",
              "            progress.value = downloaded;\n",
              "          }\n",
              "        }\n",
              "      }\n",
              "      const blob = new Blob(buffers, {type: 'application/binary'});\n",
              "      const a = document.createElement('a');\n",
              "      a.href = window.URL.createObjectURL(blob);\n",
              "      a.download = filename;\n",
              "      div.appendChild(a);\n",
              "      a.click();\n",
              "      div.remove();\n",
              "    }\n",
              "  "
            ],
            "text/plain": [
              "<IPython.core.display.Javascript object>"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "application/javascript": [
              "download(\"download_e0c246c4-ea90-4836-a758-4d34acf1ba84\", \"mft_v10.csv\", 4991450)"
            ],
            "text/plain": [
              "<IPython.core.display.Javascript object>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    }
  ]
}